<?
    $checkin = '';
    $checkout = '';
    $pets = '';
    foreach ( $object->polices as $policy => $val ):
        if ( $policy == 'Check in' )
        {
            $checkin = $val;
        }
        elseif ( $policy == 'Check out' )
        {
            $checkout = $val;
        }
        elseif ( $policy == 'Pets' )
        {
            $pets = $val;
        }

    endforeach;
?>

<div id="hotels-placeholder">

    <div id="wrap" class="clearfix">

        <div id="aside">

            <div id="changeDetasilsBox"><? $this->load->view ( 'hotels/parts/search_box' ) ?></div>

            <!-- <div id="serchModule"><? $this->load->view ( 'hotels/parts/search_box' ) ?></div> -->
            <? $this->load->view ( 'destinations/parts/banner' ) ?>
            <? $this->load->view ( 'hotels/parts/map_box' ) ?>
            <? $this->load->view ( 'parts/two_column' ) ?>

        </div><!-- / Aside -->

        <div id="main" itemscope itemtype="http://schema.org/LodgingBusiness">

            <!--HOTEL TITLE-->
            <div class="title">

                <? $pices = explode ( " ", $object->object_name ); ?>

                <h1 itemprop="name"><span><?= $pices[0] ?></span><?
                        for ( $j = 1; $j <= count ( $pices ) - 1; $j++ )
                        {
                            echo ' ' . $pices[$j];
                        }
                    ?><? if ( $object->object_number_of_stars != "" ): ?><em class="hotel-rating stars-<?= $object->object_number_of_stars ?>"></em><? endif; ?></h1>

            </div>

            <!-- REVIEWS -->
            <div class="hotel-reviews" id="hotel-reviews" style="display:none">
                <? $this->load->view ( 'hotels/reviews' ) ?>
            </div>

            <!--HOTEL TOP DESCRIPTION AND POLICES-->
            <div class="details-page clearfix" id="swich_hotel_content" style="display:block">   

                <? $preview = $host_url . 'gallery/' . $object->photos[0]->path . '/thumb_273x206/' . $object->photos[0]->photo_name; ?>

                <img itemprop="image" src="<?= $preview ?>" alt="<?= $object->object_name ?>" class="details-thumb" width="250">   

                <div class="details-info">

                    <?= strip_tags ( $object->object_address, '<p><a><h1><h2><h3><h4><h5><h6><b><strong>' ) ?>

                    <? if ( $this->lang->lang () == 'ru' ): ?>
                            <style type="text/css">
                                dt,dd {
                                    font-size: 11px;
                                }
                                #hotels-placeholder .details-info{
                                    width: 287px;
                                }
                                #hotels-placeholder .details-page .details-info dl dt {
                                    width: 115px;
                                    padding-left: 1px
                                }
                                #hotels-placeholder .details-page .details-info dl dd {
                                    width: 166px;
                                }
                            </style>
                        <? endif; ?>

                    <dl>

                        <dt><?= lang ( 'search.check_in_short' ) ?></dt>
                        <dd><?= $object->object_from ?>h</dd>

                        <dt><?= lang ( 'search.check_out_short' ) ?></dt>
                        <dd><?= $object->object_to ?>h</dd>

                        <? if ( $pets != '' ): ?>
                                <dt><?= lang ( 'hotel.pets' ) ?></dt>
                                <dd><?
                                    str_replace ( '.', "", $pets );

                                    $str = clean_html ( $pets );

                                    $lng = 24;

                                    if ( $this->lang->lang () == 'me' )
                                        $lng = 30;

                                    if ( mb_strlen ( $str ) > $lng )
                                    {
                                        $str = mb_substr ( $str, 0, $lng ) . ' <span class="tooltip read_more" title="' . $pets . '">»</span>';
                                    }
                                    if ( $str != '' )
                                        echo $str;
                                    else
                                        echo '&nbsp;';
                                    ?></dd>
                            <? endif; ?>

                        <? if ( $object->object_cancellation != "" ): ?>
                                <dt><?= lang ( 'hotel.cancelation' ) ?></dt>
                                <dd>
                                    <?
                                    $str = clean_html ( $object->object_cancellation );

                                    $lng = 23;

                                    if ( mb_strlen ( $str ) > $lng )
                                    {
                                        $str = mb_substr ( $str, 0, $lng ) . ' <span class="tooltip read_more" title="' . $object->object_cancellation . '">»</span>';
                                    }
                                    if ( $str != '' )
                                        echo $str;
                                    else
                                        echo '&nbsp;';
                                    ?>


                                </dd>
                            <? endif; ?>

                        <? if ( $object->object_extra_bed != "" ): ?>
                                <dt><?= lang ( 'hotel.extra_bed' ) ?></dt>
                                <dd>
                                    <?
                                    $str = clean_html ( $object->object_extra_bed );

                                    $lng = 20;

                                    if ( mb_strlen ( $str ) > $lng )
                                    {
                                        $str = mb_substr ( $str, 0, $lng ) . ' <span class="tooltip read_more" title="' . $object->object_extra_bed . '">»</span>';
                                    }
                                    if ( $str != '' )
                                        echo $str;
                                    else
                                        echo '&nbsp;';
                                    ?>
                                    <br>
                                    <br>

                                </dd>
                            <? endif; ?>

                    </dl>



                    <a href="javascript:" class="view_all_reviews"><?= lang ( 'hotel.see_reviews' ) ?></a>
                    <div class="star-rating-box">
                        <? if ( $object->avg_reviews_score != 0 ): ?>
                                <small>Score: <?= $object->avg_reviews_score ?></small>
                            <? endif; ?>
                        <? if ( $object->object_number_of_stars != "" ): ?>
                                <? $this->load->view ( 'rentacar/parts/rating', array ('no' => 1, 'score' => $object->object_number_of_stars) ); ?>
                            <? endif; ?>
                    </div>


                    <? if ( isset ( $object->rooms[0]->selling_total ) ): ?>

                            <a class="button" href="#go_to_rooms" style="float:right; margin-left:15px;"><?= lang ( 'shared.book.now' ) ?> »</a>
                        <? endif; ?>


                    <? if ( isset ( $object->rooms[0]->selling_total ) ): ?>
                            <span class='big'><span></span><?= $object->rooms[0]->selling_total ?>€</span>
                        <? endif; ?>

                </div>
                <?
                    if ( $object->total_reviews > 0 )
                    {
                        ?>
                        <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
                            <meta itemprop="bestRating" content="10" />				
                            <meta itemprop="worstRating" content="1" />				
                            <meta itemprop="ratingValue" content="<?= $object->avg_reviews_score == 0 ? 5 : $object->avg_reviews_score ?>" />	
                            <meta itemprop="reviewCount" content="<?= $object->total_reviews ?>" >
                        </div>		
                    <? } ?>
                <div itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">						
                    <meta itemprop="latitude" content="<?= $object->object_x_coordinate ?>" />				
                    <meta itemprop="longitude" content="<?= $object->object_y_coordinate ?>" />				
                </div>
                <div style="clear:both"></div>


                <!--AVAILABILITY FORM-->

                <? if ( $this->router->fetch_method() == 'details_preview' ): ?>

                        <?
                        if ( isset ( $session['is_post_room_search'] ) )
                        {
                            ?>
                            <br/>
                            <div class="available_info">

                                <span class="exclamation">&nbsp;!&nbsp;</span>
                                <div class="not-available">There are no rooms available in this period.</div>

                            </div>

                            <script type="text/javascript">
                                var is_post_room_search = true;
                            </script>

                        <? } ?>

                        <div class="details-book-now excursions-book-now">

                            <form method="get" action="<?= base_url ( 'hotels/details' ) ?>" id="excusrsionsBook">

                                <input type="hidden" name="hotel_id" value="<?= $object->object_ID ?>" />
                                <input type="hidden" name="is_post_room_search" value="1" />

                                <div class="three-col">
                                    <div class="right book-price fix_hotels_abs_btn">

                                        <div class="abs-ages">

                                            <div class="col clearfix ages2" <? if ( isset ( $session['nr_childrens'] ) && $session['nr_childrens'] != 0 ) echo 'style="display:block"'; ?>>

                                                <label><?= lang ( 'hotel.age' ) ?></label>

                                                <div class="left mr10 age-11"><input type="text" name="ages[]" class="positive-integer" value="<? if ( isset ( $session['ages'][0] ) ) echo $session['ages'][0]; ?>" /></div>  
                                                <div class="left mr10 age-12"><input type="text" name="ages[]" class="positive-integer" value="<? if ( isset ( $session['ages'][1] ) ) echo $session['ages'][1]; ?>" /></div>  
                                                <div class="left mr10 age-13"><input type="text" name="ages[]" class="positive-integer" value="<? if ( isset ( $session['ages'][2] ) ) echo $session['ages'][2]; ?>" /></div>  
                                                <div class="left mr10 age-14"><input type="text" name="ages[]" class="positive-integer" value="<? if ( isset ( $session['ages'][3] ) ) echo $session['ages'][3]; ?>" /></div>  
                                                <div class="left mr10 age-15"><input type="text" name="ages[]" class="positive-integer" value="<? if ( isset ( $session['ages'][4] ) ) echo $session['ages'][4]; ?>" /></div>   

                                            </div>

                                        </div>

                                        <? if ( $this->lang->lang () == 'me' || $this->lang->lang () == 'de' ): ?>
                                            <style type="text/css">
                                                .confirm_availability {
                                                    font-size: 10px !important;
                                                }
                                            </style>
                                        <? endif; ?>

                                        <button class="button confirm_availability"><?= lang ( 'hotel.check_availability' ) ?> &raquo;</button>

                                    </div>
                                    <ul class="two-columns clearfix me_two_columns_fix fix_width_dropdown">
                                        <li class="left hotels-booking-left">

                                            <ul class="side-form">

                                                <li class="clearfix">
                                                    <label><?= lang ( 'search.check_in' ) ?></label>
                                                    <input type="text" name="check_in" id="ckeck_in2" value="" />
                                                </li>

                                                <li class="clearfix">
                                                    <label><?= lang ( 'search.check_out' ) ?></label>
                                                    <input type="text" name="check_out" id="check_out2" value="" />
                                                </li>

                                            </ul>
                                        </li>

                                        <li class="right">

                                            <ul class="side-form">

                                                <li class="clearfix">
                                                    <label><?= lang ( 'adults' ) ?>:</label>
                                                    <select name="nr_adults" id="nr_adults2" class="dropdownized">
                                                        <option value="1" <? if ( isset ( $session['nr_adults'] ) && $session['nr_adults'] == 1 ) echo 'selected="selected"'; ?>>1</option>
                                                        <option value="2" <? if ( isset ( $session['nr_adults'] ) && $session['nr_adults'] == 2 ) echo 'selected="selected"'; ?> <? if ( !isset ( $session['nr_adults'] ) ) echo 'selected="selected"'; ?>>2</option>
                                                        <option value="3" <? if ( isset ( $session['nr_adults'] ) && $session['nr_adults'] == 3 ) echo 'selected="selected"'; ?>>3</option>
                                                        <option value="4" <? if ( isset ( $session['nr_adults'] ) && $session['nr_adults'] == 4 ) echo 'selected="selected"'; ?>>4</option>
                                                        <option value="5" <? if ( isset ( $session['nr_adults'] ) && $session['nr_adults'] == 5 ) echo 'selected="selected"'; ?>>5</option>
                                                    </select>
                                                </li>

                                                <li class="clearfix">
                                                    <label><?= lang ( 'children' ) ?>:</label>
                                                    <select name="nr_childrens" id="nr_childrens2" class="dropdownized">
                                                        <option value="0" <? if ( isset ( $session['nr_childrens'] ) && $session['nr_childrens'] == 0 ) echo 'selected="selected"'; ?> <? if ( !isset ( $session['nr_childrens'] ) ) echo 'selected="selected"'; ?>>0</option>
                                                        <option value="1" <? if ( isset ( $session['nr_childrens'] ) && $session['nr_childrens'] == 1 ) echo 'selected="selected"'; ?>>1</option>
                                                        <option value="2" <? if ( isset ( $session['nr_childrens'] ) && $session['nr_childrens'] == 2 ) echo 'selected="selected"'; ?>>2</option>
                                                        <option value="3" <? if ( isset ( $session['nr_childrens'] ) && $session['nr_childrens'] == 3 ) echo 'selected="selected"'; ?>>3</option>
                                                        <option value="4" <? if ( isset ( $session['nr_childrens'] ) && $session['nr_childrens'] == 4 ) echo 'selected="selected"'; ?>>4</option>
                                                        <option value="5" <? if ( isset ( $session['nr_childrens'] ) && $session['nr_childrens'] == 5 ) echo 'selected="selected"'; ?>>5</option>
                                                    </select>
                                                </li>

                                            </ul>
                                        </li>
                                    </ul>

                                </div>

                            </form>
                        </div>

                    <? endif; ?>

                <!--HOTEL INFORMATION-->
                <h2><?= str_replace ( '{|0|}', $object->object_name, lang ( 'details-for' ) ) ?></h2>
                <div class="accomodation-info clearfix" itemprop="description">
                    <div class="content-img-box right">

                        <?
                            $dest_image = $host_url . 'gallery/destinations/' . $object->destination_photo_path . '/thumb_132x132/' . $object->destination_photo_name;
                        ?>

                        <img alt="<?= $object->destination_name ?>" src="<?= $dest_image ?>" title="<?= $object->destination_name ?>">

                        <a href="<?= base_url ( 'destinations/' . urlify::filter ( $object->destination_name ) . '-' . $object->destination_ID ) ?>"><?= $object->destination_name ?></a>

                    </div>
                    <?= strip_tags ( $object->object_info, '<p><a><h1><h2><h3><h4><h5><h6><b><strong>' ) ?>
                </div>

                <!--HOTEL ROOMS-->
                <? if ( isset ( $object->rooms ) && count ( $object->rooms ) > 0 && $this->router->fetch_method () != 'details_preview'): ?>

                        <h2><?= lang ( 'hotel.availability' ) ?></h2>

                        <div class="accomodation-info">

                            <? $no_night = calculateDays ( $session['check_in'], $session['check_out'] ); ?>

                            <p><?= lang ( 'secure.available_rooms_from' ) . ' <b>' . $session['check_in'] . '</b> ' . lang ( 'secure.to' ) . ' <b>' . $session['check_out'] ?></b>, <?= lang ( 'hotel.for' ) ?> <b><?= $no_night; ?> <?
                                    if ( $no_night == 1 )
                                        echo lang ( 'secure.night' );
                                    else
                                        echo lang ( 'secure.nights' );
                                    ?> </b></p>
                        </div>

                        <table  id="go_to_rooms" style="border-spacing:0; padding:0">
                            <thead>
                                <tr>
                                    <th><?= lang ( 'hotel.room_type' ) ?></th>
                                    <th><?= lang ( 'hotel.conditions' ) ?></th>
                                    <!--                                    <th>Max</th>
                                    <th>Price</th>-->
                                    <th><?= lang ( 'hotel.reservation' ) ?></th>
                                </tr>
                            </thead>
                            <tbody>

                                <? foreach ( $object->rooms as $room ): ?>

                                    <tr>
                                        <td class="clearfix">

                                            <div class="photo">

                                                <? if ( isset ( $room->photos[0] ) ): ?>

                                                    <? $preview = $host_url . 'gallery/gallery_' . $object->object_ID . '/rooms/' . $room->photos[0]->path . '/' . '/thumb_398x236/' . $room->photos[0]->photo_name; ?>
                                                    <? $thumbnail = $host_url . 'gallery/gallery_' . $object->object_ID . '/rooms/' . $room->photos[0]->path . '/' . '/thumb_93x73/' . $room->photos[0]->photo_name; ?>

                                                    <a href="<?= $preview ?>" class="preview roomHandler" onClick="return false;">

                                                        <img src="<?= $thumbnail ?>" alt="<?= $object->object_name; ?>" />

                                                    </a>

                                                <? endif; ?>
                                            </div>

                                            <div class="holder">

                                                <div class="title tooltip" title="<b><?=
                                                lang ( "room." . underscore ( $room->room_type_name ) );

                                                if ( $room->room_description != "" )
                                                    echo " " . $room->room_description;
                                                ?></b>"><a href="javascript:" class="roomHandler"><?=
                                                     lang ( "room." . underscore ( $room->room_type_name ) );

                                                     if ( $room->room_description != "" )
                                                         echo " " . $room->room_description;
                                                     ?></a></div>

                                                <? if ( $room->room_units_left == 1 ): ?>

                                                    <div class="units_left_wrap">

                                                        <span class="units_left tooltip" title="<?= lang ( 'hotel.only' ) ?> <?= $room->room_available_units ?> <?= lang ( 'hotel.left' ) ?> <?= lang ( 'hotel.for' ) ?> <?= $room->selling_total ?> &euro;. <?= lang ( 'hotel.more_available' ) ?>">
                                                            <?= lang ( 'hotel.only' ) ?> <?= $room->room_available_units ?> <?= lang ( 'hotel.left' ) ?>
                                                        </span>

                                                    </div>

                                                <? endif; ?>

                                                <? if ( isset ( $room->room_info ) ): ?>

                                                    <p class="info">
                                                        <?
                                                        $str = clean_html ( $room->room_info );

                                                        if ( $room->room_units_left == 1 )
                                                        {
                                                            $lng = 34;
                                                        }
                                                        else
                                                        {
                                                            $lng = 63;
                                                        }

                                                        if ( mb_strlen ( $str ) > $lng )
                                                        {
                                                            //$str=mb_substr($str, 0, $lng).' <span class="tooltip read_room" title="'.$room->room_info.'">»</span>';
                                                            $str = mb_substr ( $str, 0, $lng ) . '...';
                                                        }
                                                        echo $str;
                                                        ?>
                                                    </p>

                                                <? endif; ?>

                                                <div class="max_price_wrap clearfix">

                                                    <div>
                                                        <div title="&lt;B&gt;<?= lang ( 'max_persons' ) ?>: <?= $room->room_max_person ?>&lt;/b&gt;" class="tooltip max_ps ps_<?= $room->room_max_person ?>"></div>
                                                    </div>

                                                    <span class="price"><?= $room->selling_total ?>€</span>

                                                </div>

                                            </div>

                                        </td>

                                        <td>
                                            <div class="relative">

                                                                                                            <!--                                                <div class="cancelation tooltip" title="<?= $room->room_cancellation ?>"></div>-->

                                                <div class="info"><?= $room->service_name ?></div>

                                                <? if ( $room->room_free_storno == 1 ): ?>

                                                    <div class="info"><span class="green">FREE cancellation</span> </div>

                                                <? endif; ?>

                                            </div>
                                        </td>
                                        <!--                                        <td><div title="<b>Max Persons: <?= $room->room_max_person ?></b>" class="tooltip max_ps ps_<?= $room->room_max_person ?>"></div></td>
                                        <td><div class="price"><?= $room->selling_total ?> &euro;</div></td>-->
                                        <td>
                                            <div class="relative">

                                                <a href="<?= base_url ( "hotels/checkout?room_id=" . $room->room_ID . "&amp;" . http_build_query ( $session, '', '&amp;' ) ); ?>" class="button"><?= lang ( 'shared.book.now' ) ?> »</a>

                                            </div>

                                        </td>
                                    </tr>

                                    <tr class="extendedRow">
                                        <td colspan="2">
                                            <div>
                                                <a class="close_button_roomstable" title="Close"></a>

                                                <?
                                                if ( isset ( $room->photos[0] ) ):
                                                    foreach ( $room->photos as $photo ):
                                                        $preview = $host_url . 'gallery/gallery_' . $object->object_ID . '/rooms/' . $photo->path . '/' . '/thumb_398x236/' . $photo->photo_name;
                                                        $thumbnail = $host_url . 'gallery/gallery_' . $object->object_ID . '/rooms/' . $photo->path . '/' . '/thumb_93x73/' . $photo->photo_name;
                                                        ?>

                                                        <img src="<?= $thumbnail ?>" alt="<?= $object->object_name; ?>" />

                                                        <?
                                                    endforeach;
                                                endif;
                                                ?>

                                                <br/>
                                                <br/>

                                                <?= $room->room_info ?>
                                                <?= $room->room_cancellation ?>
                                            </div>
                                        </td>
                                        <td>&nbsp;</td>
                                    </tr>

                                <? endforeach; ?>

                            </tbody>

                        </table>

                    <? endif; ?>


                <!--HOTEL FACILITIES-->
                <h2><?= lang ( 'hotel.facilities' ) ?> <?= lang ( 'hotel.of' ) ?> <?= $object->object_name ?></h2>

                <div class="facilities">

                    <ul class="clearfix">
                        <?
                            foreach ( $object->facilities as $facility => $val ):
                                $facil_arr = explode ( ',', $val );

                                foreach ( $facil_arr as $facility ):
                                    $facility = trim ( $facility );
                                    if ( $facility != "" ):
                                        ?>
                                        <li><?= $facility ?></li>
                                        <?
                                    endif;

                                endforeach;
                            endforeach;
                        ?>

                    </ul>

                </div>

                <!--HOTEL GALLERY-->
                <h2><?= lang ( 'details.gallery' ) ?></h2>

                <ul class="thumb-list">

                    <?
                        if ( isset ( $object->photos ) && count ( $object->photos ) > 1 ):
                            array_splice ( $object->photos, 0, 1 );
                            $counter = 1;
                            foreach ( $object->photos as $photo ):
                                if ( $counter <= 12 ):
                                    $thumb = $host_url . 'gallery/' . $photo->path . '/thumb_176x127/' . $photo->photo_name;
                                    $image = $host_url . 'gallery/' . $photo->path . '/thumb_800x600/' . $photo->photo_name;
                                    ?>
                                    <li itemprop="photo" itemscope itemtype="http://schema.org/ImageObject">
                                        <meta itemprop="contentUrl" content="<?= $image ?>" >
                                        <a class="lightbox" title="<?= $object->object_name ?>" href="<?= $image ?>">
                                            <img src="<?= $thumb ?>" alt="<?= $object->object_name ?>">
                                        </a>
                                    </li>
                                    <?
                                    $counter++;
                                endif;
                            endforeach;
                        endif;
                    ?>
                </ul>

            </div><!-- / Three Columns -->

        </div><!-- / Main -->

    </div><!-- / Wrap -->
</div>

<div id="google_box" style="">
    <div class="clearfix">

        <div id="google_map">
            <div id="map_canvas" style="width:100%; height:100%"></div>
        </div>

    </div>

</div>

<script type="text/javascript">

                    var LOADMAP = false;

</script>
<?
    if ( isset ( $object->object_x_coordinate ) && $object->object_x_coordinate != "" ):
        if ( isset ( $object->object_y_coordinate ) && $object->object_y_coordinate != "" ):
            ?>

            <script type="text/javascript">

                var LOADMAP = true;

            </script>

            <?
        endif;
    endif;
?>


<script type="text/javascript">

    var do_gallery = false;

<? if ( count ( $object->photos ) > 1 ): ?>
            do_gallery = true;
    <? endif; ?>

    var check_in = "<? if ( isset ( $session['check_in'] ) ) echo $session['check_in']; ?>";
    var check_out = "<? if ( isset ( $session['check_out'] ) ) echo $session['check_out']; ?>";
</script>